﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SGTD.Entidades;
using System.Data.SqlClient;
using System.Data;

namespace SGTD.DAO
{
    public class clsCargoDAO
    {
        public List<clsCargo> ListarCargo()
        {
            SqlConnection conexion = clsConexion.ObtenerConexion();
            SqlCommand cmd = new SqlCommand("listar_cargos_pa", conexion);
            cmd.CommandType = CommandType.StoredProcedure;

            SqlDataReader dr = cmd.ExecuteReader();

            List<clsCargo> lista = new List<clsCargo>();
            clsCargo c = null;

            while (dr.Read())
            {
                c = new clsCargo();

                c.IdCargo = Convert.ToInt32(dr["IdCargo"]);
                c.Nombre = Convert.ToString(dr["Nombre"]);
                lista.Add(c);
            }

            conexion.Close();
            return lista;
        }
    }
}
